load("//tools:defaults.bzl", "jasmine_node_test", "ng_module", "ng_package", "ng_test_library")

package(default_visibility = ["//visibility:public"])

ng_module(
    name = "common",
    package_name = "@nguniversal/common",
    srcs = glob([
        "*.ts",
        "src/**/*.ts",
    ]),
    deps = [
        "//modules/common/engine",
        "@npm//@angular/common",
        "@npm//@angular/core",
        "@npm//@angular/platform-browser",
        "@npm//rxjs",
    ],
)

ng_package(
    name = "npm_package",
    package_name = "@nguniversal/common",
    srcs = [":package.json"],
    readme_md = ":README.md",
    tags = ["release"],
    deps = [
        ":common",
        "//modules/common/clover",
        "//modules/common/clover/server",
        "//modules/common/engine",
        "//modules/common/tools",
    ],
)

# work-around for ng_package not providing its output in runfiles
filegroup(
    name = "npm_package_runfiles",
    srcs = [":npm_package"],
    data = [":npm_package"],
    visibility = [
        "//integration:__subpackages__",
    ],
)

ng_test_library(
    name = "unit_test_lib",
    srcs = glob([
        "spec/**/*.spec.ts",
    ]),
    entry_point = ":spec/transfer_http.spec.ts",
    deps = [
        ":common",
        "@npm//@angular/common",
        "@npm//@angular/compiler",
        "@npm//rxjs",
    ],
)

jasmine_node_test(
    name = "unit_test",
    srcs = [
        ":unit_test_lib",
    ],
)
